//
//  PHMainViewController.swift
//  PHWeibo
//
//  Created by 潘荟 on 16/7/19.
//  Copyright © 2016年 BAT. All rights reserved.
//

import UIKit

class PHMainViewController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()
        
        let tabBar = PHTabBar()
        tabBar.closure = {
            print("aaaaaaaa")
        }
        
        setValue(tabBar, forKey: "tabBar")
        
        addChildViewController(PHHomeViewController(), title: "首页", imageName: "tabbar_home")
        addChildViewController(PHMessageViewController(), title: "消息", imageName: "tabbar_message_center")
        addChildViewController(PHDiscoverViewController(), title: "发现", imageName: "tabbar_discover")
        addChildViewController(PHProfileViewController(), title: "我", imageName: "tabbar_profile")
        
    }

    
    func addChildViewController(vc:UIViewController,title:String,imageName:String) {
        
        
        vc.navigationItem.title = title
        vc.tabBarItem.title = title
        vc.tabBarItem.image = UIImage(named: imageName)?.imageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal)
        
        vc.tabBarItem.selectedImage = UIImage(named: "\(imageName)_selected")?.imageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal)
        //设置字体颜色
        vc.tabBarItem.setTitleTextAttributes([NSForegroundColorAttributeName: themeColor], forState: UIControlState.Selected)
        
        addChildViewController(UINavigationController(rootViewController: vc))
        
        
    }
    

}
